max_weigh=10000
metal_num=5
metal_weight=[1,43,35,43,87]
metal_all_prime=[43,323,45,54,43]
metal_per_prime=[metal_all_prime[x]/float(metal_weight[x]) for x in range(metal_num)]
prime_pack=0
while max_weigh>0 and metal_num!=0:
    max_index=metal_per_prime.index(max(metal_per_prime))
    if(metal_weight[max_index]>=max_weigh):
        prime_pack+=max_weigh*metal_per_prime[max_index]
        max_weigh=0
    else:
        prime_pack+=metal_all_prime[max_index]
        max_weigh-=metal_weight[max_index]
        del metal_all_prime[max_index]
        del metal_per_prime[max_index]
        del metal_weight[max_index]
        metal_num-=1
print(prime_pack)